package com.glela.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.glela.order.model.request.RequestAfterSalesModel;
import com.glela.order.service.OrderStatusService;
import com.glela.platform.constant.ErrorEnum;
import com.glela.platform.model.response.ResponseBaseModel;

@Controller
// @RequestMapping("/test")
public class TestController {
	
	@Autowired
	private OrderStatusService orderStatusService;
	
	@RequestMapping(value = "/statusTest1", method = RequestMethod.POST, consumes = "application/json")
	public ResponseEntity<?> statusTest1(@RequestBody RequestAfterSalesModel model) throws Exception{
		orderStatusService.orderDelivery(model.getAfterSn());
		return new ResponseEntity<>(new ResponseBaseModel(ErrorEnum.C10000), HttpStatus.OK);
	}
	
	@RequestMapping(value = "/statusTest2", method = RequestMethod.POST, consumes = "application/json")
	public ResponseEntity<?> statusTest2(@RequestBody RequestAfterSalesModel model) throws Exception{
		orderStatusService.confirmOrder(model.getAfterSn());
		return new ResponseEntity<>(new ResponseBaseModel(ErrorEnum.C10000), HttpStatus.OK);
	}
	
	/*@RequestMapping(value = "/statusTest3", method = RequestMethod.POST, consumes = "application/json")
	public ResponseEntity<?> statusTest3(@RequestBody RequestAfterSalesModel model) throws Exception{
		orderStatusService.closeOrder(model.getAfterSalesId());
		return new ResponseEntity<>(new ResponseBaseModel(ErrorEnum.C10000), HttpStatus.OK);
	}*/
	
	@RequestMapping(value = "/statusTest4", method = RequestMethod.POST, consumes = "application/json")
	public ResponseEntity<?> statusTest4(@RequestBody RequestAfterSalesModel model) throws Exception{
		orderStatusService.successPayment(model.getAfterSn());
		return new ResponseEntity<>(new ResponseBaseModel(ErrorEnum.C10000), HttpStatus.OK);
	}

}
